﻿/************************************************************************

 This file is part of EscapeFromPrisonPlanet.

 EscapeFromPrisonPlanet is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 EscapeFromPrisonPlanet is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with Foobar.  If not, see <http://www.gnu.org/licenses/>.

************************************************************************/

// All code (c)2012 Scott Bevin. all rights reserved

using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace LudumDare25Project.Objects
{
    internal class Pickup
    {
        public enum Types
        {
            Health,
            Shield,
            Missiles,
            Bomb,

            Max,
        }

        public Vector2 Position = Vector2.Zero;
        private Texture2D Texture = null;

        public Types Type;

        public float Rotation = 0.0f;
        private float rotAdd;

        public float Radius;
        public bool Kill = false;

        private float colorWave = 0.0f;

        public Pickup(Types type, Texture2D texture)
        {
            this.Type = type;
            Texture = texture;

            Radius = (float)Math.Sqrt((texture.Width * texture.Width) + (texture.Height * texture.Height));
            Radius *= 0.5f;

            Random rnd = new Random();
            rotAdd = ((float)rnd.NextDouble() * 2.0f) - 1.0f;
        }

        public void Update(float dt)
        {
            Position.X -= (300.0f * dt);
            Rotation += rotAdd * dt;

            colorWave += (dt * 3.0f);
        }

        public void Render(SpriteBatch sprites)
        {
            sprites.Draw(Texture, Position, null, Color.Lerp(Color.White, Type == Types.Bomb ? Color.Red : Color.Green, (float)Math.Sin(colorWave)), Rotation,
                new Vector2(Texture.Width, Texture.Height) * 0.5f, 1.0f, SpriteEffects.None, 0.0f);
        }
    }
}